/**防止重复点击重复弹出message弹框 */
import { ElMessage } from 'element-plus'
let messageInstance = null
const resetMessage = (options) => {
  if (messageInstance) {
    messageInstance.close()
  }
  messageInstance = ElMessage(options)
}
/**设置message弹框的格式 */
;['error', 'success', 'info', 'warning'].forEach((item) => {
  resetMessage[item] = (msg) => {
    return ElMessage({
      showClose: true,
      duration: 2000,
      type: item,
      message: msg
    })
  }
})
export const message = resetMessage
